package com.oop.demo05;

//学生 is 人 ：派生类 子类
//子类继承了父类，就会拥有父类的全部方法！
//Ctrl+H : 打开继承树
public class Student extends Person{
    private String name = "xiaohong";

    public Student() {
        //隐藏代码：调用了父类的无参构造
        super();   //调用父类的构造器，必须要在子类构造器的第一行
        //this("hello");
        System.out.println("Student无参构造执行了！");
    }

    public Student(String name) {
        this.name = name;
    }

    public void print() {
        System.out.println("Student");
    }

    public void test1(){
        print();    //Student
        this.print();   //Student
        super.print();  //Person
    }

    public void test(String name){
        System.out.println(name);       //小明
        System.out.println(this.name);  //xiaohong
        System.out.println(super.name); //xiaoming
    }
}
